package ar.edu.sovietrussia.customcomponents.bookviews;

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.model.IModel;

import dtos.BookInfoDTO;

/**
 */
public class ListBookModel implements IModel<List<BookModel>> {

    private List<BookModel> model;

    private static final long serialVersionUID = 1L;

    public ListBookModel(final List<BookInfoDTO> books) {
        this.model = this.wrapList(books);
    }

    public ListBookModel() {
    	this.model = new ArrayList<BookModel>();
    }

	private List<BookModel> wrapList(final List<BookInfoDTO> books) {
        List<BookModel> list = new ArrayList<BookModel>();
        for (BookInfoDTO bi : books) {
            list.add(new BookModel(bi));
        }

        return list;
    }

    /**
     * 
     */
    @Override
    public void detach() {
        // documento esto
    }

    @Override
    public List<BookModel> getObject() {
        return this.model;
    }

    public List<BookModel> getModel() {
        return this.model;
    }

    public void setModel(final List<BookModel> model) {
        this.model = model;
    }

    public static long getSerialversionuid() {
        return serialVersionUID;
    }

    @Override
    public void setObject(final List<BookModel> object) {
        this.model = object;
    }

}
